package com.blb.ssm.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.blb.ssm.service.OrderService;

@Component
@RequestMapping("/order")
public class OrderController {
	
	@Autowired
	private OrderService orderService;
	
	@RequestMapping("/in")
	public String getOrderList() {
		return "order";
	}
	
	@RequestMapping("/out")
	public String getOrderoutList() {
		return "orderout";
	}
	
	@ResponseBody
	@RequestMapping("/list")
	public  Map<String,Object> getOrderListAll(String ostate,String otype,int page) throws Exception {
		Map<String, Object> map = new HashMap<String,Object>();
		List<Map<String, Object>> olist=orderService.getlist(ostate,otype,page);
		int count=orderService.getCount(ostate,otype);
		map.put("code", 0);
		map.put("count", count);
		map.put("data", olist);
		return map;
	}
	
	@ResponseBody
	@RequestMapping("/deleteliID")
	public  String getDeleteOrder(String oid,String ostate,String otype) throws Exception {
		try {
			orderService.getDeleteOrder(oid,ostate,otype);
			return "ok";
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
}
